package blogs.eidos.cloud.framework.common.exception;


import net.bigdata.cloud.framework.common.enums.ResultCode;

import java.text.MessageFormat;

/**
 * @author ： Eidos
 * @date ：Created in 2021/5/6
 * @description：
 * @modified By：
 * @version: 1.0
 */
public abstract class AbstractCrispsException extends RuntimeException {
    private static final long serialVersionUID = 8247610319171014183L;
    private Integer code = 5000;
    private String message = "服务异常,请稍后再试!";

    public AbstractCrispsException(ResultCode resultCode, Throwable cause) {
        super(resultCode.getMessage(), cause);
        this.code = resultCode.getCode();
        this.message = resultCode.getMessage();
    }

    public AbstractCrispsException(Integer code, String message, Throwable cause) {
        super(message, cause);
        this.code = code;
        this.message = message;
    }

    public AbstractCrispsException(Integer code, String message) {
        super(message);
        this.code = code;
        this.message = message;
    }

    public AbstractCrispsException(Throwable cause) {
        super(cause);
    }

    public AbstractCrispsException(String message) {
        super(message);
        this.message = message;
    }

    public AbstractCrispsException() {
        super("crisps framework base异常");
    }

    public AbstractCrispsException(Throwable cause, String pattern, Object... params) {
        super(MessageFormat.format(pattern, params), cause);
        this.message = MessageFormat.format(pattern, params);
    }

    public AbstractCrispsException(String pattern, Object... params) {
        super(MessageFormat.format(pattern, params));
        this.message = MessageFormat.format(pattern, params);
    }

    public Integer getCode() {
        return this.code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return this.message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
